package com.atwork.wuhua.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.atwork.wuhua.ConstantsMyself;
import com.atwork.wuhua.R;
import com.atwork.wuhua.adapter.PostDetailAdapter;
import com.atwork.wuhua.base.BaseActivity;
import com.atwork.wuhua.bean.CommentBean;
import com.atwork.wuhua.utils.LogUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 社区帖子 详情
 */
public class PostDetailActivity extends BaseActivity {

    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.img_right)
    ImageView imgRight;
    @BindView(R.id.rv_comment)
    RecyclerView rvComment;
    @BindView(R.id.img_zan)
    ImageView imgZan;
    @BindView(R.id.tv_zan)
    TextView tvZan;
    private String id;

    private List<CommentBean> commentBeans;
    private PostDetailAdapter postDetailAdapter;

    @Override
    protected boolean isBindEventBus() {
        return false;
    }

    @Override
    public int intiLayout() {
        return R.layout.activity_post_detail;
    }

    @Override
    public void initView() {
        if (getIntent().getExtras() != null) {
            id = getIntent().getExtras().getString(ConstantsMyself.INTENTID);
            LogUtils.e("id==>" + id);
        }
        tvTitle.setText("社区");


        commentBeans = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            commentBeans.add(new CommentBean("" + i));
        }


        LinearLayoutManager manager = new LinearLayoutManager(this);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        rvComment.setLayoutManager(manager);
        postDetailAdapter = new PostDetailAdapter(this, R.layout.item_post_detail, commentBeans);
        rvComment.setAdapter(postDetailAdapter);
        postDetailAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                Intent intent = null;
                switch (view.getId()) {
                    case R.id.img_thumb:
                        intent = new Intent(PostDetailActivity.this, PersonInfoActivity.class);
                        intent.putExtra(ConstantsMyself.INTENTID, position + "");
                        startActivity(intent);
                        break;
                    case R.id.tv_content:
                        intent = new Intent(PostDetailActivity.this, ReplyActivity.class);
                        intent.putExtra(ConstantsMyself.INTENTID, position + "");
                        startActivity(intent);

                        break;
                }
            }
        });
    }

    @Override
    public void initData() {

    }


    @OnClick({R.id.img_left, R.id.rly_right, R.id.lly_zan, R.id.lly_report})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_left:
                finish();
                break;
            case R.id.rly_right:
                break;
            case R.id.lly_zan:
                break;
            case R.id.lly_report:
                break;
        }
    }
}
